//
// Created by vcq on 21/4/2.
//
#include "model/_teachgoal_judge.hpp"
static void GetTeachGoalJudge(request &req, response &res) {
    basic_string_view<char> id = req.get_query_value("id");
    basic_string_view<char> goal_id = req.get_query_value("goal_id");
    basic_string_view<char> _judge_id = req.get_query_value("_judge_id");
    basic_string_view<char> _syllabus_id = req.get_query_value("_syllabus_id");
    json item = MGetTeachGoalJudge(id, goal_id, _judge_id, _syllabus_id);
    res.set_status_and_content(status_type::ok, item.dump(), req_content_type::json);
}

static void SaveTeachGoalJudge(request &req, response &res) {
    if (!check_login(req, res)) {
        return;
    }
    struct _teachgoal_judge _teachgoal_judge1{};
    _teachgoal_judge1.id = atoi(req.get_query_value("id").data());
    _teachgoal_judge1._judge_id = atoi(req.get_query_value("_judge_id").data());
    _teachgoal_judge1._goal_id = atoi(req.get_query_value("_goal_id").data());
    _teachgoal_judge1.note = req.get_query_value("note");
    _teachgoal_judge1._syllabus_id = atoi(req.get_query_value("_syllabus_id").data());
    _teachgoal_judge1.per = atof(req.get_query_value("_goal_id").data());
    MAddTeachGoalJudge(_teachgoal_judge1);
    res.set_status_and_content(status_type::ok);
}


static void DeleteTeachGoalJudge(request& req, response& res) {
    if(!check_login(req,res)){
        return;
    }
    MDeleteTeachGoalJudge(req.get_query_value("id"));
    res.set_status_and_content(status_type::ok);
}
